/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.factory;

import org.hamcrest.Matcher;
import ru.jSky.matcher.MatcherAdapter;
import ru.jSky.producer.Producer;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.Major;
import ru.jSky.interfaces.additional.Enchantmentable;
import ru.jSky.matcher.RegexMatcher;

/**
 *
 * @author Rakev
 */
public class MajorMatcherFactory {
    
    private static MajorMatcherFactory instance = new MajorMatcherFactory();

    private MajorProducerFactory producerFactory = MajorProducerFactory.create();
    
    public static MajorMatcherFactory create(){
        return instance;
    }

    public <T extends Major> Matcher<T> create(String regexEdid) {
        Matcher<String> regexMatcher = new RegexMatcher(regexEdid);
        Producer<T, String> edidProducer = producerFactory.createEdidProducer();
        return AdapterMatcherFactory.create().create(edidProducer, regexMatcher);
    }

    public <T extends Enchantmentable> Matcher<T> create(Matcher<Enchantment> enchantmentMatcher) {
        Producer<T, Enchantment> edidProducer = producerFactory.createEnchantmentProducer();
        return new MatcherAdapter<>(edidProducer, enchantmentMatcher);
    }
}
